<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css"
        integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
    <!-- CSS外部样式表 -->
    <title>
        {%block title%}

        {%endblock%}
    </title>
</head>

<body>
    <!-- Navbar here -->
    <nav class="navbar navbar-expand-md navbar-dark bg-dark">
        <a class="navbar-brand" href='#'>Flask Market</a>
        <!-- 直接导到func而不是使用hard-coded url -->
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav mr-auto">
                <li class="nav-item active">
                    <a class="nav-link" href="{{ url_for('home_page')}}">Home <span class="sr-only">(current)</span></a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('market_page')}}">Market</a>
                </li>
            </ul>
            {% if current_user.is_authenticated %}
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" style="color:lawngreen;font-weight:bold">
                        <i class="fas fa-coins"></i>
                        {{current_user.prettier_budget}}
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Welcome,{{ current_user.username }}</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('logout_page')}}">Logout</a>
                </li>
            </ul>
            {%else%}
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('login_page')}}">Login</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('register_page') }}">Register</a>
                </li>
            </ul>
            {%endif%}
        </div>
    </nav>
    <!-- with 设置了作用域，with一开始就可以定义变量，定义的变量作用域在with和endwith之间 -->
    {% with messages=get_flashed_messages(with_categories=true) %}
    {% if messages %}
    {% for category,message in messages %}
    <div class="alert alert-{{category}}">
        <button type="button" class="m1-2 mb-1 close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
        </button>
        {{ category, message }}
    </div>
    {% endfor %}
    {% endif %}
    {%endwith%}
    <!-- 用于提示错误的代码 -->
    <!-- Future Content here -->
    {%block content%}

    {%endblock%}

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src='https://kit.fontawesome.com/a076d05399.js'></script>
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
        integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
        crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"
        integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
        crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"
        integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV"
        crossorigin="anonymous"></script>
</body>
<style>
    body {
        background-color: #212121;
        color: white;
        opacity: 0.8;
    }
</style>
<!-- CSS样式表 -->

</html>